var series=$("#evaluateSeries").attr("val");
var displacement=$("#evaluateDisplacement").attr("val");
var brandChange = function(){
	var evaluateBrand = $("#evaluateBrand").val();
	$("#evaluateSeries").empty();
	var option = document.createElement("option");
	option.text = "正在加载...";
	option.value = "";
	$("#evaluateSeries")[0].options.add(option);
	$.ajax({
		url : contextPath+"/getEvaluateSeries/" + + encodeURI(encodeURI(evaluateBrand)),
		dataType : 'json',
		cache : false,
		//async:false,//同步
		success : function(result) {
			$("#evaluateSeries").empty();
			var option = document.createElement("option");
			option.text = "请选择车系";
			option.value = "";
			$("#evaluateSeries")[0].options.add(option);
			$("#evaluateDisplacement").empty();
			var option = document.createElement("option");
			option.text = "请选择排量";
			option.value = "";
			$("#evaluateDisplacement")[0].options.add(option);
			for(var i in result){
				var option = document.createElement("option");
				option.disabled = "disabled";
				option.text = i;
				option.value = "";
				$("#evaluateSeries")[0].options.add(option);
				var model = result[i];
				for(var j in model){
					var option = document.createElement("option");
					option.text = "　" + model[j];
					option.value = j;
					$("#evaluateSeries")[0].options.add(option);
				}
			}
			if(series!=""){
				$("#evaluateSeries").val(series);
				seriesChange();
				series="";
			}
		},
		error:function(){
			$("#evaluateSeries").empty();
			var option = document.createElement("option");
			option.text = "加载失败";
			option.value = "";
			$("#evaluateSeries")[0].options.add(option);
		}
	});
	$("#brand").val($('#evaluateBrand').find("option:selected").val());
};
$("#evaluateBrand").bind('change',brandChange);
var seriesChange = function(){
	var seriesId = $("#evaluateSeries").val();
	$("#evaluateDisplacement").empty();
	var option = document.createElement("option");
	option.text = "正在加载...";
	option.value = "";
	$("#evaluateDisplacement")[0].options.add(option);
	$.ajax({
		url : contextPath+"/getEvaluateDisplacements/" + seriesId,
		dataType : 'json',
		cache : false,
		//async:false,//同步
		success : function(result) {
			$("#evaluateDisplacement").empty();
			var option = document.createElement("option");
			option.text = "请选择排量";
			option.value = "";
			$("#evaluateDisplacement")[0].options.add(option);
			for(var i in result){
				var option = document.createElement("option");
				option.text = result[i];
				option.value = result[i];
				$("#evaluateDisplacement")[0].options.add(option);
			}
			if(displacement!=""){
				$("#evaluateDisplacement").val(displacement);
				displacement="";
			}
		},
		error:function(){
			$("#evaluateDisplacement").empty();
			var option = document.createElement("option");
			option.text = "加载失败";
			option.value = "";
			$("#evaluateDisplacement")[0].options.add(option);
		}
	});
	$("#model").val($('#evaluateSeries').find("option:selected").text());
} ;
$("#evaluateSeries").bind('change',seriesChange);
$.ajax({
	url : contextPath+"/getEvaluateBrands",
	dataType : 'json',
	cache : true,
	ifModified: false,
	success : function(result) {
		$("#evaluateBrand").empty();
		var option = document.createElement("option");
		option.text = "请选择品牌";
		option.value = "";
		$("#evaluateBrand")[0].options.add(option);
		for(var i in result){
			var option = document.createElement("option");
			option.text = i;
			option.value = result[i];
			$("#evaluateBrand")[0].options.add(option);
		}
		if($("#brand").val()){
			$("#evaluateBrand").val($("#brand").val());
			brandChange();
		}
	},
	error:function(){
	}
});
var pingjia = false;
$("span.radio").bind("click",function(e){
	if(!pingjia){
		$(this).addClass("radio-checked");
		alert("感谢您的评价!");
		pingjia = true;
	}
});